Plex.Lib.JS.load('Data.Jax');
Plex.Lib.JS.load('Data.XT');
Plex.Lib.JS.load('UI.Page.Intro');
Plex.Lib.JS.load('UI.Button.Large_Text');

Plex.Com.Module[8] = function(pageInfo)
{
	var self = this;

	this.info = pageInfo;
	this.page = new Plex.UI.Page.Intro();

	this.Jax = new Plex.Data.Jax();
	this.Jax.async=false;
	this.Jax.feed='Property';
	this.Jax.action='Language_Search';
	this.Jax.Var('property_ID',Plex.Settings.propertyId);

	this.Jax.handler=function(feed)
	{
		var languages = feed.getElementsByTagName('results').item(0).childNodes;

		for(var i=0;i<languages.length;i++)
		{
			var
			language = Plex.Data.XT.getAttributes(languages[i]),
			button = new Plex.UI.Button.Large_Text();

			button.setTitle(language.greeting);
			button.language = language;
			
			button.onclick=function()
			{
				var lang = this.language;
				
				Plex.Settings.languageId = lang.language_ID;
				Plex.Settings.ratingSystemId = lang.rating_system_ID;

				if(lang.main_menu_page_ID==0)
				{
					Plex.Util.Error.push("No Homepage For This Language Set Yet");
					return;
				}

				var page = new Plex.Com.Page.load(lang.main_menu_page_ID);
			}

			button.moveTo(self.page.body);
		}

		self.open();
	}
	
	Plex.Com.Page.register(this);
	this.Jax.Call();
}